package com.cq.hd.product.api.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;

@Data
public class ActiveReleaseDto implements Serializable {

    @ApiModelProperty(value = "活动id（去发布必传）")
    private Long id;

    @ApiModelProperty(value = "用户id")
    private Long userId;

    @ApiModelProperty(value = "商家id")
    private Long businessId;

    @ApiModelProperty(value = "活动类型(1-团购活动，2-报名活动，3-外部活动, 4-团购+报名活动)")
    private Integer activeType;

    @NotBlank(message = "请输入活动标题")
    @ApiModelProperty(value = "活动标题")
    private String activeTitle;

    @NotBlank(message = "请上传活动图片")
    @ApiModelProperty(value = "活动图片")
    private String activeImg;

//    @ApiModelProperty(value = "活动内容")
//    private String content;

    @NotEmpty(message = "请输入活动内容")
    @ApiModelProperty(value = "活动内容")
    private List<ActiveContent> activeContents;

    // 活动商品列表
    @ApiModelProperty(value = "活动商品列表")
    private List<ActiveGoodsSonDto> activeGoods;

    @ApiModelProperty(value = "补贴设置(0-未设置,1-自动按比例分摊,2-手动设置)")
    private Integer subsidyState;

    // 活动商品补贴列表
    @ApiModelProperty(value = "活动商品补贴列表")
    private List<ActiveGoodsSubsidySonDto> activeGoodsSubsidy;

    @ApiModelProperty(value = "活动价格，如果报名活动设置了阶梯价格，传0")
    private BigDecimal activePrice;

    @ApiModelProperty(value = "划线价格")
    private BigDecimal originPrice;

    @ApiModelProperty(value = "多件多折状态(1-关闭，2-开启)")
    private Integer discountState;

    // 多件多折列表
    @ApiModelProperty(value = "多件多折列表")
    private List<ActiveDiscountSonDto> activeDiscount;

    @ApiModelProperty(value = "活动总库存")
    private Integer totalStock;

    @ApiModelProperty(value = "活动开始时间，格式：yyyy-MM-dd HH:mm:ss")
    private String startTime;

    @ApiModelProperty(value = "活动结束时间，格式：yyyy-MM-dd HH:mm:ss")
    private String endTime;

    @ApiModelProperty(value = "活动有效开始时间，格式：yyyy-MM-dd HH:mm:ss")
    private String validStartTime;

    @ApiModelProperty(value = "活动有效结束时间，格式：yyyy-MM-dd HH:mm:ss")
    private String validEndTime;

    @ApiModelProperty(value = "限购数量")
    private Integer limitBuyNum;

    @ApiModelProperty(value = "省份id")
    private Integer provinceId;

    @ApiModelProperty(value = "省份名称")
    private String provinceName;

    @ApiModelProperty(value = "市id")
    private Integer cityId;

    @ApiModelProperty(value = "市名称")
    private String cityName;

    @ApiModelProperty(value = "区县id")
    private Integer countyId;

    @ApiModelProperty(value = "区县名称")
    private String countyName;

    @ApiModelProperty(value = "活动详细地址")
    private String address;

    @ApiModelProperty(value = "分销开启状态(1-关闭，2-开启)")
    private Integer agentState;

    @ApiModelProperty(value = "分销佣金金额")
    private BigDecimal commissionAmt;

    @ApiModelProperty(value = "分销佣金比例")
    private BigDecimal commissionRate;

    @ApiModelProperty(value = "默认佣金类型：0-无，1-佣金，2-佣金比例")
    private Integer defaultCommissionType;

    @ApiModelProperty(value = "其他权益")
    private String otherEquity;

    @ApiModelProperty(value = "是否是所有经纪人可推广：1-是，2-否")
    private Integer agentNumState;

    // 分销经纪人列表
    @ApiModelProperty(value = "分销经纪人用户列表，如果是所有经纪人，则传空，否则传经纪人用户id集合")
    private List<Long> agentIds;

    @ApiModelProperty(value = "新人首单红包")
    private ActiveRedPacketSonDto activeRedPacket;

    @ApiModelProperty(value = "是否是阶梯价格(1-否，2-是)")
    private Integer stepPriceState;

    // 阶梯价格列表
    @ApiModelProperty(value = "阶梯价格列表")
    private List<ActiveStepPriceSonDto> activeStepPrices;

    @ApiModelProperty(value = "报名人数")
    private Integer enrollNum;

    @ApiModelProperty(value = "未满员是否自动退款:1-是，2-否")
    private Integer noFullAutoRefundState;

    @ApiModelProperty(value = "报名次数限制(同个用户最多可报名几次)")
    private Integer limitEnrollNum;

    @ApiModelProperty(value = "核销方式(1-线上核销，2-线下核销)")
    private Integer verifyMethod;

    // 报名信息列表
    @ApiModelProperty(value = "报名信息列表")
    private List<ActiveEnrollInfoSonDto> activeEnrollInfos;

    @ApiModelProperty(value = "活动联系电话")
    private String activeMobile;

    @ApiModelProperty(value = "活动客服微信号")
    private String activeWechat;

    @ApiModelProperty(value = "活动链接")
    private String activeUrl;

    @ApiModelProperty(value = "活动状态（1-仅保存，2-去发布）")
    private Integer activeState;

    @ApiModelProperty(value = "核销方式（只对报名活动有效）：0-系统，1-票付通")
    private Integer verifyType;

    @ApiModelProperty(value = "票付通产品ID")
    private String pftProduct;

    @ApiModelProperty(value = "票付通门票ID")
    private String pftTicket;

    @ApiModelProperty(value = "票付通供应商ID")
    private String pftSupplier;

    @NotNull(message = "请选择零元购状态")
    @ApiModelProperty(value = "是否是零元购活动（1-不是，2-是）")
    private Integer zeroState;

    @NotNull
    @ApiModelProperty(value = "开启报名（0-不开启 1-开启）")
    private Integer enrollEnable;

    @ApiModelProperty(value = "部分核销不退款（0-关闭 1-开启）")
    private Integer refundableExpiredUnused;

    @ApiModelProperty(value = "隐藏链接（0-不隐藏 1-隐藏）")
    private Integer hideLink;

    @ApiModelProperty(value = "是否需要签到（0-否 1-是）")
    private Integer signInRequired;

    @ApiModelProperty(value = "签到费用")
    private BigDecimal signInFee;

    @ApiModelProperty(value = "是否需要审核（0-否 1-是）")
    private Integer auditRequired;

    @ApiModelProperty(value = "活动标签")
    private List<ActiveLabelDto> labels;

    @ApiModelProperty(value = "GROUP_BUY(拼团)")
    private String promotionType;

    @ApiModelProperty(value = "过期自动退款：0：关闭 1-开启")
    private Integer autoRefundEnabled;

    @ApiModelProperty(value = "奖励方式：1-佣金 3-积分")
    private Integer rewardType;

    @ApiModelProperty(value = "奖励积分")
    private BigDecimal rewardPoints;

    public BigDecimal getCommissionRate() {
        return Optional.ofNullable(this.commissionRate)
                .orElse(BigDecimal.ZERO);
    }

    public BigDecimal getCommissionAmt() {
        return Optional.ofNullable(this.commissionAmt)
                .orElse(BigDecimal.ZERO);
    }

}
